package com.tanhua.dubbo.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Questions;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface QuestionsMapper extends BaseMapper<Questions> {

    @Select("<script>"+
                "select sum(score) from tb_questions " +
                    "<foreach collection=\"questionId\" item=\"item\" open=\"where id in(\" close=\")\" separator=\",\">\n" +
            "            #{item}" +
            "        </foreach>" +
                "</script>")
    Integer sumByScore(@Param(value = "questionId") List<Integer> questionId);


}
